package vn.com.atm;

import java.util.List;

import vn.com.atm.map.CustomItemizedOverlay;
import vn.com.atm.map.CustomOverlayItem;
import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class MapViewActivity extends MapActivity{
    MapView mapView;
	private MapController mapController;
	private GeoPoint geoPoint;
	List<Overlay> mapOverlays;
	Drawable drawable;
	
	
	CustomItemizedOverlay<CustomOverlayItem> itemizedOverlay;
	@Override
    public void onCreate(Bundle savedInstanceState) {
		
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        
        mapView = (MapView)findViewById(R.id.mapView);
        mapView.setBuiltInZoomControls(true);
        mapOverlays = mapView.getOverlays();
        
     // first overlay
     		drawable = getResources().getDrawable(R.drawable.marker);
     		itemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView);
     		
       
       
        
        String[] position = {"21.785463","105.574788"};
        double latitude = Double.parseDouble(position[0]);
        double longtitude = Double.parseDouble(position[1]);
        geoPoint = new GeoPoint((int)(latitude*1E6), (int)(longtitude*1E6));
        CustomOverlayItem overlayItem = new CustomOverlayItem(geoPoint, "Tomorrow Never Dies (1997)", 
				"(M gives Bond his mission in Daimler car)", 
        		"http://ia.media-imdb.com/images/M/MV5BMTM1MTk2ODQxNV5BMl5BanBnXkFtZTcwOTY5MDg0NA@@._V1._SX40_CR0,0,40,54_.jpg");
		
        itemizedOverlay.addOverlay(overlayItem);
		mapOverlays.add(itemizedOverlay);
		
		mapController = mapView.getController();
		mapController.setZoom(12);
		mapController.animateTo(geoPoint);
	}
	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}

}
